package com.wxmit.module.system.web;

import com.wxmit.base.domain.ApiResult;
import com.wxmit.module.system.domain.SysColumnSetting;
import com.wxmit.module.system.service.SysColumnSettingService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 系统用户环境设置 controoler
 *
 * @author huangxiong
 * @version V1.0
 * @date 2022/12/5 15:46
 */
@RestController
@RequestMapping("/sys/setting/")
@RequiredArgsConstructor
public class SysUserSettingController {

    private final SysColumnSettingService sysColumnSettingService;

    /**
     *  获取 列设置
     * @param path 页面路径
     * @return 当前页 列设置
     */
    @GetMapping("columnSetting")
    public List<SysColumnSetting> getColumnSetting(@RequestParam("path") String path){
        return sysColumnSettingService.getSettingByPath(path);
    }

    @PostMapping("columnSetting")
    public ApiResult addColumnSetting(@RequestBody @Validated List<SysColumnSetting> settings){
        sysColumnSettingService.addOrUpdateBatch(settings);
        return ApiResult.success();
    }


}
